package com.game.ammo {
	import com.game.data.Data;
	import com.game.units.Enemy;
	import com.game.utils.TowerType;
	import flash.filters.GlowFilter;
	import flash.geom.Point;
	public class Spark extends Ammo {
		private var flameSize:Number = 10;
		private var position:Number = 0;
		private var p4:Point = new Point();
		private var dir:Number = 0;
		public function Spark(bulX:Number, bulY:Number, ang:Number, destination:Number, type:TowerType, upgrades:int, suggestiveDistance:int) {
			super(bulX, bulY, ang, destination, type, upgrades, suggestiveDistance);
		}
		override public function isHit(p3:Enemy):Boolean {
			if (this.pointToLineDistance(p3) < p3.size / 2 + flameSize / 2) {
				return true;
			}
			return false;
		}
		override protected function initialSet():void {
			ammoSpeed = 3;
			_damage = (upgrades + 1) * 2;
			position = Data.STEP / 2;
			p1.x = -(Data.STEP / 2) * Math.cos(this._angle);
			p1.y = -(Data.STEP / 2) * Math.sin(this._angle);
			_suggestiveDistance = Math.sqrt(_suggestiveDistance);
			p4.x = -_suggestiveDistance * Math.cos(this._angle);
			p4.y = -_suggestiveDistance * Math.sin(this._angle);
			this.depth = 0;
			//
			_rect.width = 100;
			_rect.height = 100;
			var ang:Number = (_angle * 180 / Math.PI) + 180;
			ang = ang < 0 ? 360 + ang : ang;
			_rect.x = Math.round(ang / 15) * 100;
			this._point.x = p1.x + x - 50;
			this._point.y = p1.y + y - 50;
		}
		override public function move():void {
			position += this.ammoSpeed;
			if (position > destination) {
				readyForRemoval = true;
			}
			_rect.y = (int(9 * (_suggestiveDistance / destination)) + Math.cos(dir)) * 100;
			dir += Math.PI / 2;
		}
	}
}